package movies.spring.data.neo4j.controller;

import movies.spring.data.neo4j.domain.Person;
import movies.spring.data.neo4j.services.PersonService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Collection;

/**
 * @author Mark Angrish
 * @author Michael J. Simons
 */
@RestController
@RequestMapping("/")
public class PersonController {

    private final PersonService personService;

    public PersonController(PersonService personService) {
        this.personService = personService;
    }

    @RequestMapping("/findPersonsByBorn")
    public Collection<Person> findPersonsByBorn(
            @RequestParam(value = "born", required = false) Integer born) {
        Collection<Person> persons = personService.findPersonsByBorn(born);
        return persons;
    }
}
